#pragma once
#include "../lua/ELuna.h"
#include "../gge/ggesound.h"
#include "../gge/ggebase.h"
#include "../gge/ggemusic.h"

#include <list>

namespace gge { typedef guint32 gUInt; }
class LuaSound
{
public:
	LuaSound();
	~LuaSound();
	void Play(gge::gUInt ptr, int size, bool bLoop);
	void PlayMusic(gge::gUInt ptr, int size, bool bLoop);
// 	bool PlayEx(int volume, int pan, float pitch, bool bLoop);
// 	bool IsPlaying();
// 
// 	void Stop();
// 	void Pause() ;
// 	void Resume() ;
// 	void SetPan(int v) ;
	void SetVolume(int v) ;
// 	void SetPitch(float v) ;
// 	UINT GetP();
// 	int	 GetRefCount();
// 	void AddRef();
// 	void Release();
private:
//	gge::ggeSound* m_p = nullptr;
	gge::ggeMusic* m_music = nullptr;
	std::list<gge::ggeSound*> _sounds;
	int _volume = 100;
};


struct IDirectSoundBuffer;
class cWav
{
public:
	~cWav();
	static cWav* getInstance();

	void load(const char* data, int size);

	void load(const char* pdata, int size, int pos, bool bPlay);

private:
	void free();

	void setPosition(int num);

	int getNowPostion();

	//	LPDIRECTSOUNDBUFFER m_pPrimaryBuffer = nullptr;
	IDirectSoundBuffer* m_pPrimaryBuffer = nullptr;
	int m_size;
	bool bLoad = false;

	std::list<const char*> _caches;
};